<?php
define("GRID_SOURCE", "");
include(GRID_SOURCE . "class/gridclasses.php"); //Include the grid engine.
require_once "../funciones.php";
//Define identifying name(s) to your grid(s). Must be unqiue name(s).
$grid_id = array("grid");

//Remember to comment the again line when publishing PHP Grid, or else PHP Grid wont remember the settings between page loads.
unset($_SESSION["grid"]);
include(GRID_SOURCE . "class/gridcreate.php"); //Creates grid objects.
?>
<html>
    <title>View Grid</title>
    <head>
        <script language="Javascript" type="text/javascript" src="<?php print(GRID_SOURCE); ?>javascript/javascript.js"></script>
        <link href="<?php print(GRID_SOURCE); ?>css/style.css" rel="stylesheet" type="text/css">
        <link rel="stylesheet" type="text/css" media="screen" href="../css/caweb.css" />
        <script type='text/javascript' src="<?php print(GRID_SOURCE); ?>server.php?client=all"></script>
        <script>
            HTML_AJAX.defaultServerUrl = '<?php print(GRID_SOURCE); ?>server.php';
        </script>
        <script src="caweb2.js"></script>
        <script src="../js/jquery.js" type="text/javascript"></script>
        <script src="../js/caweb.js" type="text/javascript"></script>
    </head>
    <body>
            <form name="recogidas" method="POST" action="adiciona_rec2.php">
                <input type="hidden" name="recogida" value="<?php echo $_REQUEST['recogida'] ?>" />
                <table>
                    <tr>
                        <td>
                            <div><label for="clasetx">Clase</label>
                                <select name="clase" id="clasetx" class="mayusculas" onchange="funcion_subclases(this.value,0,1); funcion_pasasesion('clase',this.value);">
                                    <option value='' SELECTED>Seleccionar..</option>
<?php
            $link_intranetpccom = con_intranetpccom();
            $sql = "SELECT * FROM clases where estado = 1 order by descripcion";
            $result64 = mysql_query($sql, $link_intranetpccom) or die('Error Clase, ' . mysql_error() . $sql);
            while ($row64 = mysql_fetch_array($result64)) {
                echo "<option value='{$row64['codigoclase']}'>{$row64['descripcion']}</option>";
            }
?>
                            </select>
                        </div>
                    </td>
                    <td>
                        <div id="layer2_subclases"></div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div id="layer2_familias"></div>
                    </td>
                    <td>
                        <div id="layer2_grupos"></div>
                    </td>
                </tr>
                <tr>
                    <td colspan="4">
                        <label for="cantidad">Cantidad:</label>
                        <input type="text" id="cantidad" size="5" name="cantidad" value="">
                    </td>
                </tr>
            </table>
            <br>Observacion / Seriales :<input type="text" id="observacion" size="75" name="observacion" value="">
            <input name="guardar" type="submit" value="Adicionar" />
        </form>

<?php
            $link_caweb = con_caweb();
            $sql = "select transaccion from cabeceras_rec where numero = {$_REQUEST['recogida']}";
            $result = mysql_query($sql,$link_caweb) or die("Error SQL 3 ".mysql_error().$sql);
            $transaccion=  mysql_result($result, 0,"transaccion");
            echo "Ultimo Item " . $_SESSION['caweb']['ultimoitem'];
            if ($_REQUEST['resultado'] == 1) {
                echo "<font color=green><b> CORRECTO </b></font>";
            }
            if ($_REQUEST['resultado'] == 2) {
                echo "<font color=black><b> Sin datos </b></font>";
            }
            if ($_REQUEST['resultado'] == 3) {
                echo "<font color=red><b> INTERNO EN TRANSACCION $transaccion </b></font>";
            }

            $condicion = "transaccion='$transaccion'";
            $_SESSION["grid"]->SetDatabaseConnection($_SESSION['caweb']['basededatos'], "caweb", "caweb");

            $_SESSION["grid"]->SetSqlSelect('id,cantidad,pendiente,clase,item,observacion', 'temporal_rec', $condicion);
            $_SESSION["grid"]->SetUniqueDatabaseColumn("id", false);
            $_SESSION["grid"]->SetTitleName("Ingreso de Items para recogida");
            $_SESSION["grid"]->SetEditModeEdit(true);
            $_SESSION["grid"]->SetMaxRowsEachPage(15);
            $_SESSION["grid"]->SetDatabaseColumnEditable("id", false);
            $_SESSION["grid"]->SetDatabaseColumnEditable("clase", false);
            $_SESSION["grid"]->SetDatabaseColumnEditable("item", false);
            $_SESSION["grid"]->SetDatabaseColumnEditable("cantidad", true);
            $_SESSION["grid"]->SetDatabaseColumnEditable("pendiente", true);
            $_SESSION["grid"]->SetDatabaseColumnEditable("observacion", true);
            $_SESSION["grid"]->SetShowExcelIco(false);
            $_SESSION["grid"]->SetShowPrintIco(true);
            $_SESSION["grid"]->PrintGrid(MODE_EDIT);
?>
    </body>
</html>
